#!/bin/bash
api_login="cf08a76581978fcd"
api_key="UosPqI_f"
COMMAND=${@:$OPTIND:1}
ARG1=${@:$OPTIND+1:1}
ARG2=${@:$OPTIND+2:1}
folderID=$(curl -s "https://api.openload.co/1/file/listfolder?login=$api_login&key=$api_key"|grep -o "[0-9]\{1,\}\",\"name\":\"$ARG2\""|grep -o '^[0-9]\{1,\}')
case $COMMAND in
    upload)
    file_link=$ARG1
    getUpload=$(curl -s "https://api.openload.co/1/file/ul?login=$api_login&key=$api_key&folder=$folderID&httponly=true" |awk -F '\"' '{print $12}' |sed 's#\\/#/#g')
    curl -F "file1=@$file_link" $getUpload
    ;;
    remote)
    remote_url=$ARG1
    curl "https://api.openload.co/1/remotedl/add?login=$api_login&key=$api_key&folder=$folderID&url=$remote_url"
    ;;
esac
